package com.xbdun;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;

import com.xbdun.common.core.dbconfig.DataBaseConfig;
import com.xbdun.common.pkgenerators.RedisPkGenerator;
import com.xbdun.web.validatebmp.frame.AnnotationBeanNameCfg;

@SpringBootApplication
@ComponentScan(basePackageClasses={DataBaseConfig.class,ValidateWebApplication.class},nameGenerator=AnnotationBeanNameCfg.class)
@EnableCaching
public class ValidateWebApplication implements CommandLineRunner{
	//上传文件保存的地址
	@Value("${upload.save.folder}")
	private String uploadFolder = "";
	private static String  UPLOADFOLDER;
	
	@Value("${xbdun.open.shopbp.protocol}")
	private String shopProtol;//商城开放平台地址
	public static String OPEN_SHOP_GATAWAY_URL;//开放平台网关地址
	
	public static void main(String[] args) {
		SpringApplication.run(ValidateWebApplication.class, args);
	}
	public static final String getSaveFolder(){
		return UPLOADFOLDER;
	}
	public void run(String... args) throws Exception {
		if(null==UPLOADFOLDER||(!uploadFolder.equals(UPLOADFOLDER)))UPLOADFOLDER = uploadFolder;
		//统一网关地址
		ValidateWebApplication.OPEN_SHOP_GATAWAY_URL = shopProtol+"shop/gataway.zhtm";
	}
	
	/**
	* @Title: initRedisGenerator
	* @Description: RedisBeanId生成器
	* @return RedisPkGenerator    返回类型
	 */
	@Bean(initMethod="init")
	public RedisPkGenerator initRedisGenerator(){
		return new RedisPkGenerator();
	}
}